<?php

namespace app\logic;

use support\Request;
use support\think\Model;
use think\db\Query;

class BaseLogic
{



    public function toLists(Model | Query $user , Request $request) : array
    {

        $page       =  (int) $request->get('page' , 1);
        $pageLimit =   (int) $request->get('pageSize' , 15);
        return [
            'lists' =>  $user->limit( ($page - 1) * $pageLimit , $pageLimit ) -> select(),
            'total' =>  $user->count(),
            'page'  =>  $page,
            'pageSize'  =>  $pageLimit,
            'sql'   =>  $user->limit( ($page - 1) * $pageLimit , $pageLimit ) -> fetchSql(true)-> select()
        ];
    }
}